<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/bootstrap.css">
    <link rel="stylesheet" href="./css/font-awesome.min.css">
    <title>Document</title>
</head>
<body>
    <h1>用户列表</h1>
    <a href="./insert.html" class="btn btn-success"><i class="fa fa-plus-square fa-fw"></i>添加新用户</a>
    <?php
    //引入数据库文件
        require_once './conn.php';
        $result = mysqli_query($link,'select*from users');
        if(mysqli_num_rows($result)>0){
    ?>
    <table class="table table-bordered">
    <thead class="thead-dark">
      <tr>
        <th>序号</th>
        <th>id</th>
        <th>姓名</th>
        <th>邮箱</th>
        <th>电话号码</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
    <?php
      $i=1;
      while ($row=mysqli_fetch_array($result)) {
    ?>
      <tr>
        <td><?php echo $i; ?></td>
        <td><?php echo $row['id']; ?></td>
        <td><?php echo $row['name']; ?></td>
        <td><?php echo $row['email']; ?></td>
        <td><?php echo $row['mobile']; ?></td>
        <td>
            <a href="update.php?id=<?php echo $row['id']; ?>" class="btn btn-primary"><i class="fa fa-pencil fa-fw"></i>修改</a>
            <a href="delete.php?id=<?php echo $row['id']; ?>" class="btn btn-warning"><i class="fa fa-trash-o fa-fw"></i>删除</a>
        </td>
      </tr>
      <?php
        $i++;
        }
      ?>
    </tbody>
    </table>
      <?php
        }
        else {
            echo "无数据";
        }
      ?>
</body>
</html>